<?php
namespace App\Modules\Fund;
use App\Modules\AdapterApi;
use App\Services\Fund\FundIndex;
/**
 * Created by PhpStorm.
 * User: 97606
 * Date: 2018/6/12
 * Time: 10:10
 */
class FundAccount extends AdapterApi
{
    /*兑换钱*/
    public function exchange(): array
    {
        $data = pick_array($this->postData, ['exchange', 'money', 'currency_scale', 'token']);
        return FundIndex::FundAccount()->exchange($data);
    }
    # 充值 系统->a
    public function prepaid(): array
    {
        $data = pick_array($this->postData, ['user_id', 'money', 'token', 'user_info', 'opposite_info', 'remark']);
        $data['update_ip'] = request()->ip();
        if(\SYSTEM_ID == $data['user_id']){
            return \verify_err($data, '不能为系统用户充值');
        }

        return FundIndex::FundAccount()->prepaid($data);
    }
    # 冻结 a
    public function freeze(): array
    {
        $data = pick_array($this->postData, ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'user_info','opposite_info','type','obj_id','freeze_counts','reason','token']);
        return FundIndex::FundAccount()->adminFreeze($data);
    }
    # 解冻 a
    public function unfreeze(): array
    {
       $data = pick_array($this->postData, ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'user_info','opposite_info','type','obj_id','freeze_counts','remark','token'], false);
        return FundIndex::FundAccount()->unfreeze($data);
    }
    // 获取列表
    public function list(): array
    {
        $data = pick_array($this->postData, ['page', 'list_rows', 'token', 'keywords']);
        return FundIndex::FundAccount()->list($data);
    }
    // 某user_ids的用户资金列表
    public function listByUserIds(): array
    {
        $data = pick_array($this->postData, ['user_ids','token']);
        return FundIndex::FundAccount()->listByUserIds($data);
    }

}